#!/usr/bin/make -f

BUILDDIR=ipkg-build

build-stamp:
	test -d $(BUILDDIR) || mkdir $(BUILDDIR)
	(cd $(BUILDDIR); ../configure --prefix=/usr --sysconfdir=/etc/charon --localstatedir=/var/charon --host=mipsel-linux)
	make -C $(BUILDDIR)
	touch build-stamp

build: build-stamp

install-stamp: build-stamp
	make DESTDIR=/tmp/charon -C $(BUILDDIR) install
	mipsel-linux-strip --strip-unneeded /tmp/charon/usr/bin/* /tmp/charon/usr/lib/*.so
	mkdir -p /tmp/charon/www/cgi-bin /tmp/charon/etc/init.d /tmp/charon/var/charon
	ln -s /usr/bin/charon /tmp/charon/www/cgi-bin/charon
	cp init.d/iptables /tmp/charon/etc/init.d/S46charon
	touch install-stamp

install: install-stamp

clean:
	-rm -rf $(BUILDDIR) build-stamp install-stamp